package HOME_WORK;

/**
 * @author 小李不吃鱼
 * @date 2021-01-16 09:23
 */
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;
public class Class7 {
    public static void main(String[] args) {
        condigureGame(numPlayers());
    }

    // 选择人数
    public static int numPlayers() {
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入游戏人数：");
        int numPeople = sc.nextInt();
        if (numPeople > 18 || numPeople < 12) {
            System.out.println("超出游戏人数范围!");


        }
        return numPeople;
    }

    //  根据人数给游戏分组
    public static void condigureGame(int numPlayers) {
        switch (numPlayers) {
            case 12:
                numPlayers_12();
                break;

            case 13:
                numPlayers_13();
                break;
            case 14:
                numPlayers_14();
                break;
            case 15:
                numPlayers_15();
                break;
            case 16:
                numPlayers_16();
                break;
            case 17:
                numPlayers_17() ;
                break;
            case 18:
                numPlayers_18();
                break;
        }
    }

    // 12人
    public static String[] numPlayers_12() {
        //  底牌中不会出现的牌
        String[] cards1 = {"狼人", "狼人", "狼人", "盗贼"};

        Random r = new Random();
        String[] cards2 = {"村民", "村民", "村民", "村民", "狼人", "预言家", "女巫", "丘比特", "守护", "猎人", "村长"};
        for (int i = 1; i <= 100; i++) {
            int rd = r.nextInt(cards2.length);
            String temp = cards2[rd];
            cards2[rd] = cards2[cards2.length - 1];
            cards2[cards2.length - 1] = temp;
        }
        //  生成底牌holeCards
        String[] holeCards = new String[3];
        System.arraycopy(cards2, cards2.length - 3, holeCards, 0, 3);
        //  生成12个角色卡
        String[] players = new String[12];
        System.arraycopy(cards2, 0, players, 0, cards2.length - 3);
        System.arraycopy(cards1, 0, players, cards2.length - 3, cards1.length);

        for (int i = 1; i < 100; i++) {
            int rand = r.nextInt(players.length);
            String temp = players[rand];
            players[rand] = players[players.length - 1];
            players[players.length - 1] = temp;
        }
        System.out.println("玩家的手牌为：");
        System.out.println("01:" + players[0] + "02:" + players[1] + "03:" + players[2] + "04:" + players[3] + "05:" + players[4] + "06:" + players[5] + "07:" + players[6] + "08:" + players[7] + "09:" + players[8] + "10:" + players[9] + "11:" + players[10] + "12:" + players[11]);

        System.out.println("盗贼的底牌为：");
        System.out.println("01:" + holeCards[0] + "02:" + holeCards[1] + "03:" + holeCards[2]);
        return players;
    }

    //  13人时
    public static String[] numPlayers_13() {
        //  底牌中不会出现的牌
        String[] cards1 = {"狼人", "狼人", "狼人", "盗贼"};

        Random r = new Random();
        String[] cards2 = {"村民", "村民", "村民", "村民", "村民", "狼人", "预言家", "女巫", "丘比特", "守护", "猎人", "村长"};
        for (int i = 1; i <= 100; i++) {
            int rd = r.nextInt(cards2.length);
            String temp = cards2[rd];
            cards2[rd] = cards2[cards2.length - 1];
            cards2[cards2.length - 1] = temp;
        }
        //  生成底牌holeCards
        String[] holeCards = new String[3];
        System.arraycopy(cards2, cards2.length - 3, holeCards, 0, 3);
        //  生成12个角色卡
        String[] players = new String[13];
        System.arraycopy(cards2, 0, players, 0, cards2.length - 3);
        System.arraycopy(cards1, 0, players, cards2.length - 3, cards1.length);

        for (int i = 1; i < 100; i++) {
            int rand = r.nextInt(players.length);
            String temp = players[rand];
            players[rand] = players[players.length - 1];
            players[players.length - 1] = temp;
        }
        System.out.println("玩家的手牌为：");
        System.out.println("01:" + players[0] + "02:" + players[1] + "03:" + players[2] + "04:" + players[3] + "05:" + players[4] + "06:"
                + players[5] + "07:" + players[6] + "08:" + players[7] + "09:" + players[8] + "10:" + players[9] + "11:" + players[10]
                + "12:" + players[11] + "13:" + players[12]);
        System.out.println("盗贼的底牌为：");
        System.out.println("01:" + holeCards[0] + "02:" + holeCards[1] + "03:" + holeCards[2]);
        return players;
    }

    // 14人时
    public static String[] numPlayers_14() {
        //  底牌中不会出现的牌
        String[] cards1 = {"狼人", "狼人", "狼人", "盗贼"};

        Random r = new Random();
        String[] cards2 = {"村民", "村民", "村民", "村民", "村民", "狼人", "预言家", "女巫", "丘比特", "守护", "猎人", "村长", "替罪羊"};
        for (int i = 1; i <= 100; i++) {
            int rd = r.nextInt(cards2.length);
            String temp = cards2[rd];
            cards2[rd] = cards2[cards2.length - 1];
            cards2[cards2.length - 1] = temp;
        }
        //  生成底牌holeCards
        String[] holeCards = new String[3];
        System.arraycopy(cards2, cards2.length - 3, holeCards, 0, 3);
        //  生成12个角色卡
        String[] players = new String[14];
        System.arraycopy(cards2, 0, players, 0, cards2.length - 3);
        System.arraycopy(cards1, 0, players, cards2.length - 3, cards1.length);

        for (int i = 1; i < 100; i++) {
            int rand = r.nextInt(players.length);
            String temp = players[rand];
            players[rand] = players[players.length - 1];
            players[players.length - 1] = temp;
        }
        System.out.println("玩家的手牌为：");
        System.out.println("01:" + players[0] + "02:" + players[1] + "03:" + players[2] + "04:" + players[3] + "05:" + players[4] + "06:"
                + players[5] + "07:" + players[6] + "08:" + players[7] + "09:" + players[8] + "10:" + players[9] + "11:" + players[10]
                + "12:" + players[11] + "13:" + players[12] + "14:" + players[13]);
        System.out.println("盗贼的底牌为：");
        System.out.println("01:" + holeCards[0] + "02:" + holeCards[1] + "03:" + holeCards[2]);
        return players;
    }

    // 15人时
    public static String[] numPlayers_15() {
        //  底牌中不会出现的牌
        String[] cards1 = {"狼人", "狼人", "狼人", "狼人", "盗贼"};

        Random r = new Random();
        String[] cards2 = {"村民", "村民", "村民", "村民", "村民", "狼人", "预言家", "女巫", "丘比特", "守护", "猎人", "村长", "替罪羊"};
        for (int i = 1; i <= 100; i++) {
            int rd = r.nextInt(cards2.length);
            String temp = cards2[rd];
            cards2[rd] = cards2[cards2.length - 1];
            cards2[cards2.length - 1] = temp;
        }
        //  生成底牌holeCards
        String[] holeCards = new String[3];
        System.arraycopy(cards2, cards2.length - 3, holeCards, 0, 3);
        //  生成12个角色卡
        String[] players = new String[15];
        System.arraycopy(cards2, 0, players, 0, cards2.length - 3);
        System.arraycopy(cards1, 0, players, cards2.length - 3, cards1.length);

        for (int i = 1; i < 100; i++) {
            int rand = r.nextInt(players.length);
            String temp = players[rand];
            players[rand] = players[players.length - 1];
            players[players.length - 1] = temp;
        }
        System.out.println("玩家的手牌为：");
        System.out.println("01:" + players[0] + "02:" + players[1] + "03:" + players[2] + "04:" + players[3] + "05:" + players[4] + "06:"
                + players[5] + "07:" + players[6] + "08:" + players[7] + "09:" + players[8] + "10:" + players[9] + "11:" + players[10]
                + "12:" + players[11] + "13:" + players[12] + "14:" + players[13] + "15:" + players[14]);
        System.out.println("盗贼的底牌为：");
        System.out.println("01:" + holeCards[0] + "02:" + holeCards[1] + "03:" + holeCards[2]);
        return players;
    }

    // 16人时
    public static String[] numPlayers_16() {
        //  底牌中不会出现的牌
        String[] cards1 = {"狼人", "狼人", "狼人", "狼人", "盗贼"};

        Random r = new Random();
        String[] cards2 = {"村民", "村民", "村民", "村民", "村民", "村民", "狼人", "预言家", "女巫", "丘比特", "守护", "猎人", "村长", "替罪羊"};
        for (int i = 1; i <= 100; i++) {
            int rd = r.nextInt(cards2.length);
            String temp = cards2[rd];
            cards2[rd] = cards2[cards2.length - 1];
            cards2[cards2.length - 1] = temp;
        }
        //  生成底牌holeCards
        String[] holeCards = new String[3];
        System.arraycopy(cards2, cards2.length - 3, holeCards, 0, 3);
        //  生成12个角色卡
        String[] players = new String[16];
        System.arraycopy(cards2, 0, players, 0, cards2.length - 3);
        System.arraycopy(cards1, 0, players, cards2.length - 3, cards1.length);

        for (int i = 1; i < 100; i++) {
            int rand = r.nextInt(players.length);
            String temp = players[rand];
            players[rand] = players[players.length - 1];
            players[players.length - 1] = temp;
        }
        System.out.println("玩家的手牌为：");
        System.out.println("01:" + players[0] + "02:" + players[1] + "03:" + players[2] + "04:" + players[3] + "05:" + players[4] + "06:"
                + players[5] + "07:" + players[6] + "08:" + players[7] + "09:" + players[8] + "10:" + players[9] + "11:" + players[10]
                + "12:" + players[11] + "13:" + players[12] + "14:" + players[13] + "15:" + players[14] + "16:" + players[15]);
        System.out.println("盗贼的底牌为：");
        System.out.println("01:" + holeCards[0] + "02:" + holeCards[1] + "03:" + holeCards[2]);
        return players;
    }

    // 17人时
    public static String[] numPlayers_17() {
        //  底牌中不会出现的牌
        String[] cards1 = {"狼人", "狼人", "狼人", "狼人", "盗贼"};

        Random r = new Random();
        String[] cards2 = {"村民", "村民", "村民", "村民", "村民", "村民", "村民", "狼人", "预言家", "女巫", "丘比特", "守护", "猎人", "村长", "替罪羊"};
        for (int i = 1; i <= 100; i++) {
            int rd = r.nextInt(cards2.length);
            String temp = cards2[rd];
            cards2[rd] = cards2[cards2.length - 1];
            cards2[cards2.length - 1] = temp;
        }
        //  生成底牌holeCards
        String[] holeCards = new String[3];
        System.arraycopy(cards2, cards2.length - 3, holeCards, 0, 3);
        //  生成12个角色卡
        String[] players = new String[17];
        System.arraycopy(cards2, 0, players, 0, cards2.length - 3);
        System.arraycopy(cards1, 0, players, cards2.length - 3, cards1.length);

        for (int i = 1; i < 100; i++) {
            int rand = r.nextInt(players.length);
            String temp = players[rand];
            players[rand] = players[players.length - 1];
            players[players.length - 1] = temp;
        }
        System.out.println("玩家的手牌为：");
        System.out.println("01:" + players[0] + "02:" + players[1] + "03:" + players[2] + "04:" + players[3] + "05:" + players[4] + "06:"
                + players[5] + "07:" + players[6] + "08:" + players[7] + "09:" + players[8] + "10:" + players[9] + "11:" + players[10]
                + "12:" + players[11] + "13:" + players[12] + "14:" + players[13] + "15:" + players[14] + "16:" + players[15] + "17:" + players[16]);
        System.out.println("盗贼的底牌为：");
        System.out.println("01:" + holeCards[0] + "02:" + holeCards[1] + "03:" + holeCards[2]);
        return players;
    }
    // 18人时
    public static String[] numPlayers_18() {
        //  底牌中不会出现的牌
        String[] cards1 = {"狼人", "狼人", "狼人", "狼人", "盗贼"};

        Random r = new Random();
        String[] cards2 = {"村民", "村民", "村民", "村民", "村民", "村民", "村民", "狼人", "预言家", "女巫", "丘比特", "守护", "猎人", "村长", "替罪羊","吹笛者"};
        for (int i = 1; i <= 100; i++) {
            int rd = r.nextInt(cards2.length);
            String temp = cards2[rd];
            cards2[rd] = cards2[cards2.length - 1];
            cards2[cards2.length - 1] = temp;
        }
        //  生成底牌holeCards
        String[] holeCards = new String[3];
        System.arraycopy(cards2, cards2.length - 3, holeCards, 0, 3);
        //  生成12个角色卡
        String[] players = new String[18];
        System.arraycopy(cards2, 0, players, 0, cards2.length - 3);
        System.arraycopy(cards1, 0, players, cards2.length - 3, cards1.length);

        for (int i = 1; i < 100; i++) {
            int rand = r.nextInt(players.length);
            String temp = players[rand];
            players[rand] = players[players.length - 1];
            players[players.length - 1] = temp;
        }
        System.out.println("玩家的手牌为：");
        System.out.println("01:" + players[0] + "02:" + players[1] + "03:" + players[2] + "04:" + players[3] + "05:" + players[4] + "06:"
                + players[5] + "07:" + players[6] + "08:" + players[7] + "09:" + players[8] + "10:" + players[9] + "11:" + players[10]
                + "12:" + players[11] + "13:" + players[12] + "14:" + players[13] + "15:" + players[14] + "16:" + players[15]
                + "17:" + players[16] + "18:" + players[17]);
        System.out.println("盗贼的底牌为：");
        System.out.println("01:" + holeCards[0] + "02:" + holeCards[1] + "03:" + holeCards[2]);
        return players;
    }
}
